package com.tmc.dao.impl.inthotel;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.tmc.bean.inthotel.hotel.HotelPolicies;
import com.tmc.dao.impl.BaseDaoImpl;

@Repository
public class HotelPoliciesDaoImpl extends BaseDaoImpl {

	public void saveAllHotelPolicies (List<HotelPolicies> hotelPolicies){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < hotelPolicies.size(); i++) {
			session.save(hotelPolicies.get(i));
		}
		session.getTransaction().commit();
	}
	
	public void updateAllHotelPolicies (List<HotelPolicies> hotelPolicies){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < hotelPolicies.size(); i++) {
			session.update(hotelPolicies.get(i));
		}
		session.getTransaction().commit();
	}
	
	public List<HotelPolicies> findAllHotelPolicies(){
		Session session = getSession();
		String hql = "from HotelPolicies";
		Query query = session.createQuery(hql);
		List<HotelPolicies> hotelPolicies =(List<HotelPolicies>)query.list();
		session.close();
		return hotelPolicies;
	}
}
